package com.osfw.framework.core.domain;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

public class RequestPage {
    Integer pageNum = 1;
    Integer pageSize = 10;

    public RequestPage() {
    }

    public <T> Page<T> page() {
        return page(this);
    }

    public static <T> Page<T> page(RequestPage rpage) {
        if (rpage == null) {
            rpage = new RequestPage();
        }

        Integer num = rpage.getPageNum();
        if (num == null || num <= 0) {
            num = 1;
        }

        Integer size = rpage.getPageSize();
        if (size == null || size <= 0) {
            size = 10;
        }

        return new Page((long)num, (long)size);
    }

    public Integer getPageNum() {
        return this.pageNum;
    }

    public Integer getPageSize() {
        return this.pageSize;
    }

    public void setPageNum(final Integer pageNum) {
        this.pageNum = pageNum;
    }

    public void setPageSize(final Integer pageSize) {
        this.pageSize = pageSize;
    }
}
